import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 徐海涛
 * Date: 2022-04-19
 * Time: 0:46
 */
public class Demo5 {
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        StringBuilder stringBuilder = new StringBuilder(s);
        StringBuilder stringBuilder1 = stringBuilder.reverse();
        System.out.println(stringBuilder1);

    }
// 回溯
    public static void main2(String[] args) {
        Scanner s = new Scanner(System.in);
        String str1 = s.nextLine();//asdfas
        String str2 = s.nextLine();//werasdfaswer

        //System.out.println(m);
    }


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str1= scanner.nextLine();
        String str2 = scanner.nextLine();
        char[] A = str1.toCharArray();
        char[] B = str2.toCharArray();
        System.out.println(func(A,B));
    }
    //DP转移 方程 F(i,j) = F(i-1,j-1) + 1;
    public static int func(char[] A,char[] B) {
        int[][] dp = new int[A.length+1][B.length+1];//i,j
        int MaxCount = 0;//记录更新最大值
        for (int i = 1; i < A.length+1 ; i++) {
            for (int j = 1; j < B.length+1; j++) {
                if (A[i - 1] == B[j-1]) {
                    //满足动态规划
                    dp[i][j] = dp[i-1][j-1]+1;
                }
                if(MaxCount < dp[i][j]) {
                    MaxCount = dp[i][j];//不断更新
                }
            }
        }
        return MaxCount;
    }

}
